package ink.lovejinhu.leetcode;

import java.util.HashSet;

/**
 * @author jinhu
 * created 2021-08-09 14:09
 */
public class Solution_0771 {
    /**
     * 宝石与石头
     *
     * @param jewels
     * @param stones
     * @return
     */
    public int numJewelsInStones(String jewels, String stones) {
        HashSet<Character> c = new HashSet<>();
        for (int i = 0; i < jewels.length(); i++) {
            c.add(jewels.charAt(i));
        }
        int res = 0;
        for (int i = 0; i < stones.length(); i++) {
            if (c.contains(stones.charAt(i))) {
                res++;
            }
        }
        return res;
    }
}
